package com.me.shardingdemo.web.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.ToString;


@ToString
@AllArgsConstructor
@NoArgsConstructor
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum GenderEnum implements IEnum<Integer> {

    MALE(0, "男"),
    FEMALE(1, "女");

    @EnumValue
    private int value;
    private String desc;

    @JsonCreator
    public static GenderEnum getItem(int code) {
        for (GenderEnum item : values()) {
            if (item.getValue() == code) {
                return item;
            }
        }
        return null;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
